"""
类依赖项-官方文档：https://fastapi.tiangolo.com/zh/tutorial/dependencies/classes-as-dependencies/
"""
from fastapi import Depends, Query
from core.dependencies import Paging, QueryParams


class TestcaseParams(QueryParams):
    """
    列表分页
    """

    def __init__(
            self,
            caselib_id: int,
            status: int | str | None = None,
            level: str | None = None,
            title: str | None = Query(None, title="用例库名称"),
            params: Paging = Depends(),
    ):
        super().__init__(params)
        self.title = ("like", title)
        self.v_order = "desc"
        self.v_order_field = "id"
        self.caselib_id = caselib_id
        if status is not None and status != "":
            self.status = status
        if level is not None and level != "":
            self.level = level


class TestcaseVersion(QueryParams):
    def __init__(self, version_id: int):
        super().__init__()
        self.version_id = version_id
